package com.huawei.java.main.classes;

public class Service {
    private final String type;
    private final int cpu;
    private final int memory;
    private final boolean doubleDeploy;

    public Service(String type, int cpu, int memory, boolean doubleDeploy) {
        this.type = type;
        this.cpu = cpu;
        this.memory = memory;
        this.doubleDeploy = doubleDeploy;
    }

    public Service(String describe) {
        final String substring = describe.substring(1, describe.length() - 1);
        final String[] parts = substring.split("\\s*,\\s*");
        this.type = parts[0];
        this.cpu = Integer.parseInt(parts[1]);
        this.memory = Integer.parseInt(parts[2]);
        this.doubleDeploy = Integer.parseInt(parts[3]) == 1;
    }

    public String getType() {
        return type;
    }

    public int getCpu() {
        return cpu;
    }

    public int getMemory() {
        return memory;
    }

    public boolean isDoubleDeploy() {
        return doubleDeploy;
    }
}
